package com.zxmr.domain.service;

import java.sql.SQLException;
import java.util.List;

import com.zxmr.CommonInit;
import com.zxmr.db.DBManager;
import com.zxmr.domain.Report;

public class ReportService {

	DBManager db = CommonInit.getDBManager();
	
	public int add(Report report)
	{
		try
		{
			System.out.println("content is : "+report.getContent());
			return (Integer)db.getMapper().insert("report.add", report);
		}catch(SQLException e)
		{
			e.printStackTrace();
		}
		return -1;
	}
	
	public Report query(int id)
	{
		try
		{
			return (Report)db.getMapper().queryForObject("report.findByID", id);
		}catch(SQLException e)
		{
			e.printStackTrace();
		}
		return null;
	}
	@SuppressWarnings("unchecked")
	public List<Report> queryContractPagination(ReportSearchBean bean)
	{
		try {
			return (List<Report>)db.getMapper().queryForList("report.searchPagination", bean);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}
	public int queryContractPaginationCount(ReportSearchBean bean)
	{
		try {
			return (Integer)db.getMapper().queryForObject("report.findCountPagination", bean);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return -1;
	}
}
